package com.workday.gridsimulator

import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.actor.Props

/**
 * Singleton for creating SimpleJobWorker actors
 * 
 *  Implements the WorkerCreation trait 
 */
object SimpleJobWorkerCreation extends WorkerCreation {

  override def createWorkers(firstWorkerId: Int, workerCount: Int, ec2InstanceType: Ec2Instance, clockActor: ActorRef, gridActor: ActorRef, actorSystem: ActorSystem) = {

    for (i <- 1 to workerCount) {
      val worker = actorSystem.actorOf(Props(new SimpleJobWorker(firstWorkerId + i, ec2InstanceType, gridActor, clockActor)))
      clockActor ! AddMe(worker)
      worker ! RegisterWithGrid
    }

  }

}